#include "gtest/gtest.h"
#include "../ParaCoordCalctor.h"
using SG::FEMSolver::Element::quad4ComputeIntegCoord;

TEST (Quad4ComputeIntegCoordTest, RegularShapeCase)
{
    SG::Algebra::Matrix point(1,3,{-0.5883484054145518,0,3.4694469519536142e-16});
    SG::Algebra::Matrix plane(4,2,{
        -2.5495097567963927,-2.5,
        2.5495097567963927,-2.5,
        2.5495097567963927,2.5,
        -2.5495097567963927,2.5});

    // Test data 
    Real  xiTest, etaTest;
    quad4ComputeIntegCoord (point,plane,_OUT xiTest,_OUT etaTest);
    // Target data
    const Real xiTarget = -0.23076923076923062;
    const Real etaTarget = 0.0;

    // Check
    ASSERT_TRUE(xiTest  == xiTarget);
    ASSERT_TRUE(etaTest == etaTarget);

}

TEST (Quad4ComputeIntegCoordTest, IrregularShapeCase)
{
    SG::Algebra::Matrix point(1,3,{-2.6839216360982014 , -2.0548347625256769 ,0 });
    SG::Algebra::Matrix plane(4,2,{
        -3.7678306004658637 ,     -4.6311968017126039,
         2.4688024422756536 ,     -4.2226526912610005,
         4.3097850826496948 ,      5.9193778213060675,
        -3.0107569244594843 ,      2.934471671667537
    });

    // Test data 
    Real  xiTest, etaTest;
    quad4ComputeIntegCoord (point,plane,_OUT xiTest,_OUT etaTest);
    // Target data
    const Real xiTarget = -0.74423588078005865;
    const Real etaTarget = -0.36058970195014695;

    // Check
    ASSERT_TRUE(xiTest  == xiTarget);
    ASSERT_TRUE(etaTest == etaTarget);
}